package org.example.map;

import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.api.functions.source.ParallelSourceFunction;
import org.apache.flink.streaming.api.functions.source.SourceFunction;

import java.util.UUID;
import java.util.concurrent.TimeUnit;

/**
 * map 算子
 */
public class DataMapStream {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        DataStreamSource<Integer> source = env.fromElements(1, 2, 3);
        /**lambda表达式*/
//        source.map(x -> x * x).print();
        /**显示算子*/
//        source.map(new MyMap()).print();
        /**匿名类实现*/
        source.map((MapFunction<Integer, Integer>) value -> {
            System.out.println("-----" + value);
            return value * 3;
        }).print();

        env.execute();
    }
}